#include <ctime>
#include <iostream>
#include "agent01.h"

using namespace std;

double getP(){
    return ((double)rand())/((double)RAND_MAX);
}

int main(){
    const int numberOfKeywords=15;
    srand(time(NULL));

    agent01* a1 = new agent01(15,1000);

    //Testing Receive info
    cout << "Testing receiveInfo() 10 times" << endl;
    for(int i=0;i<10;i++){
        try {
        int month = rand()%4;
        int day = rand()%7;
        int imps[numberOfKeywords];
        int clicks[numberOfKeywords];
        double cost[numberOfKeywords];
        double position[numberOfKeywords];
        for(int j=0;j<numberOfKeywords;j++){
            imps[j]=rand();
            clicks[j]=rand();
            cost[j]=1000.0*getP();
            position[j]=15.0*getP();
        }
        a1->receiveInfo(month,day,imps,clicks,cost,position);
        }
        catch(...)
        {
            cout << "Error during test " << i << endl;
        }
    }
    cout << "Testing receiveInfo() done!" << endl;

    //Testing getBidsForAllKeywords
    cout << "Testing getBidsForAllKeywords() 10 times" << endl;
    for(int i=0;i<10;i++){
        double* tmp = a1->getBidsForAllKeywords();
        delete tmp;
    }
    cout << "Testing getBidsForAllKeywords() done!" << endl;

    //Testing getMaxBudgetForAllKeywords
    cout << "Testing getMaxBudgetForAllKeywords() 10 times" << endl;
    for(int i=0;i<10;i++){
        double* tmp = a1->getMaxBudgetForAllKeywords();
        delete tmp;
    }
    cout << "Testing getMaxBudgetForAllKeywords() done!" << endl;

    cout << endl << "All tests were run succesfully!" << endl;

    delete a1;

    return 0;
}

